﻿using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;

namespace Naruto.TaskManagement.Infrastructure
{
    public static class JsonExtensions
    {

        public static string ToJson<T>(this T source)
        {
            if (source == null)
            {
                return default;
            }
            return JsonConvert.SerializeObject(source);
        }

        public static T ToObject<T>(this string source)
        {
            if (source.IsNullEmpty())
            {
                return default;
            }
            return JsonConvert.DeserializeObject<T>(source);
        }
    }
}
